package com.fandy.struts.SqlStatement;

public class Stock {
 
	public   String  getAll()
	{
		return   "select * from Stock";
	}
	
	public   String getStockInfoByDepID(int DepID)
	{
		return  "select * from Stock where " +com.fandy.struts.Meta.Stock.getDepartmentid()+"="+DepID;
	}
	
	public   String getStockInfoByGoodID(int GoodsID)
	{
		return  "select * from Stock where " +com.fandy.struts.Meta.Stock.getGoodsid()+"="+GoodsID;
	}
		
	
	public   String  existStock(com.fandy.struts.Model.Stock s)
	{
		return  "select count(*) from Stock where "+com.fandy.struts.Meta.Stock.getDepartmentid()+"= "
		+s.getDepartmentid()+" "
		+"and "+com.fandy.struts.Meta.Stock.getGoodsid()+" = " 
		+ s.getGoodsid() 
		;
	}
	
	public String UpdateByID(int oldDepid,int oldGoodID,com.fandy.struts.Model.Stock s)
	{
		
		return "update Stock set "+com.fandy.struts.Meta.Stock.getDepartmentid()
		+"='" + s.getDepartmentid()+"',"		 
		+com.fandy.struts.Meta.Stock.getGoodsid() +"='" +s.getGoodsid()+"',"
		+com.fandy.struts.Meta.Stock.getPrice() + "='"  + s.getPrice() + "',"
		+com.fandy.struts.Meta.Stock.getQuantity() + "='"  + s.getQuantity() + "',"
		+com.fandy.struts.Meta.Stock.getRemark() + "='"  + s.getRemark() + "',"
						
		+"where "+com.fandy.struts.Meta.Stock.getDepartmentid()+"="+oldDepid+
		" and "+com.fandy.struts.Meta.Stock.getGoodsid()+"="+oldGoodID
		;
		
	}
	
	public String DeleteByID(int depId, int GoodsID)
	{
		
		return "delete from Stock where " + com.fandy.struts.Meta.Stock.getDepartmentid() +"="+depId
		+	" and "+com.fandy.struts.Meta.Stock.getGoodsid()+"="+GoodsID
		;
		
	}
	
	
	
}

